/**
 * Video favs
 */
var fav = {
	
	add : function(key) {
		debug.print("fav.add [key: "+key+"]");
		if (!player[key].video) {
			flash.flash('No video', 'loaded');
			return false;
		}
		if (!user.isLoggedIn()) {
			flash.flash('You must be','logged in to do this');
		} else {
			$.post(
				"/video/addFav/json",
				{
					video_id: player[key].video.id,
				},
				function(data) {
					if (data.status === true) {
						flash.flash('Favourite','added');
						fav.on(key);
					} else if (data.status === 'duplicate') {
						flash.flash('You already','favourited this video');
					} else {
						flash.flash('Error','while adding video to favourites');
					}								
				},
				"json"
			);			
		}
	},
	
	on : function(key) {
		$("#vid" + key + "-fav-button").addClass('on');
	},
	
	off : function(key) {
		$("#vid" + key + "-fav-button").removeClass('on');
	},
	
}